<html lang="en-US">

<head>
    
<title>K8s安装 - 花落雨忧</title>

<meta property="og:title" content="K8s安装 - 花落雨忧">



    



    
    <meta property="description" content="背景：和docker-compose一样，k8s也是容器编排工具，但k8s是一个更复杂的容器编排系统，用于管理大规模的容器化应用。
核心定位
[&amp;hellip;] 核心功能对比
[&amp;hellip;] 适用场景
Docker Compose适用场景
[&amp;hellip;] Kubernetes适用场景
[&amp;hellip;] 配置文件示例：
Docker &amp;hellip;">
    <meta property="og:description" content="背景：和docker-compose一样，k8s也是容器编排工具，但k8s是一个更复杂的容器编排系统，用于管理大规模的容器化应用。
核心定位
[&amp;hellip;] 核心功能对比
[&amp;hellip;] 适用场景
Docker Compose适用场景
[&amp;hellip;] Kubernetes适用场景
[&amp;hellip;] 配置文件示例：
Docker &amp;hellip;">
    






<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1">

<link rel="shortcut icon" href="https://www.lican.asia/logo/logo.png" type="image/x-icon" />



<link rel="stylesheet" href="/css/style.min.css" />

<link rel="stylesheet" href="/css/reset.min.css" />




<script src="https://www.lican.asia/js/highlight.min.js"></script>

<script>
hljs.configure({ ignoreUnescapedHTML: true })
hljs.highlightAll();
</script>


<script src="https://www.lican.asia/js/jquery.min.js"></script>




<link href="https://www.lican.asia/css/hugo-code.min.css" rel="stylesheet" />



    <style>
        .post-content img {
            max-width: 400px;
        }
    </style>
</head>

<body id="period" class="home blog">
    <a class="skip-content" href="#main">Press "Enter" to skip to content</a>
    <div id="overflow-container" class="overflow-container">
        <header class="site-header" id="site-header" role="banner">
    <div class="max-width">
        <div id="title-container" class="title-container">
            <div id="site-title" class="site-title"><a href="/">花落雨忧</a></div>
            <p class="tagline">思所及 力所行 方为真.</p>
        </div>
        
        <div id="menu-primary-container" class="menu-primary-container">
            <div class="icon-container">
            </div>
            <div id="menu-primary" class="menu-container menu-primary" role="navigation">
                <nav class="menu">
                    <ul id="menu-primary-items" class="menu-primary-items">
                        
                        
                        <li id="menu-item-0"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/posts" aria-current="page" tabindex="0">首页</a></li>
                        
                        <li id="menu-item-1"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/tech/" aria-current="page" tabindex="1">技术文档</a></li>
                        
                        <li id="menu-item-2"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/article/" aria-current="page" tabindex="2">文章</a></li>
                        
                        <li id="menu-item-3"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/project/" aria-current="page" tabindex="3">项目</a></li>
                        
                        <li id="menu-item-4"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/about/" aria-current="page" tabindex="4">关于</a></li>
                        
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</header>

        <div id="primary-container" class="primary-container">
            <div class="max-width">
                <section id="main" class="main" role="main">
                    <div id="loop-container" class="loop-container">
                        <div
                            class="post type-post status-publish format-standard hentry entry">
                            <article>
                                <div class="post-container">
                                    <div class="post-header">
                                        <h2 class="post-title">
                                            <a href="/tech/k8s%E5%AE%89%E8%A3%85/">K8s安装</a>
                                        </h2>
                                        
                                    </div>
                                    <div class="post-content">
                                        <h3 id="k8s安装">k8s安装</h3>
<p>背景：和docker-compose一样，k8s也是容器编排工具，但k8s是一个更复杂的容器编排系统，用于管理大规模的容器化应用。</p>
<p>核心定位</p>
<table>
<thead>
<tr>
<th>维度</th>
<th>Docker Compose</th>
<th>Kubernetes</th>
</tr>
</thead>
<tbody>
<tr>
<td>目标场景</td>
<td>单机开发，测试环境(单节点)</td>
<td>生产多节点集群，大规模分布式应用</td>
</tr>
<tr>
<td>功能定位</td>
<td>定义和运行多容器应用(开发友好)</td>
<td>容器编排，集群管理，自动化运维</td>
</tr>
<tr>
<td>学习曲线</td>
<td>简单(YAML语法直观)</td>
<td>陡峭(需掌握Pod, Service, Ingress等核心概念)</td>
</tr>
</tbody>
</table>
<p>核心功能对比</p>
<table>
<thead>
<tr>
<th>功能</th>
<th>Docker Compose</th>
<th>Kubernetes</th>
</tr>
</thead>
<tbody>
<tr>
<td>容器编排</td>
<td>单机多容器编排(通过docker-compose.yml)</td>
<td>跨节点容器编排(支持回滚更新，回滚，副本管理)</td>
</tr>
<tr>
<td>扩展性</td>
<td>仅单机扩展(依赖宿主机资源)</td>
<td>动态扩缩容(HPA), 多接点集群自动调度</td>
</tr>
<tr>
<td>高可用性</td>
<td>不支持(单点故障风险)</td>
<td>支持(Pod自动重启，节点故障转移)</td>
</tr>
<tr>
<td>网络管理</td>
<td>简单容器间网络(自定义网络)</td>
<td>复杂网络策略(NetworkPolicy, Service发现)</td>
</tr>
<tr>
<td>存储管理</td>
<td>本地卷或命名卷</td>
<td>动态卷供应(PV/PVC),支持云存储和分布式存储</td>
</tr>
<tr>
<td>负载均衡</td>
<td>无内置负载均衡</td>
<td>Service和Ingress支持负载均衡</td>
</tr>
<tr>
<td>监控与日志</td>
<td>依赖外部工具(如Prometheus+Grafana)</td>
<td>集成监控(Metrics Server)，日志聚合方案丰富</td>
</tr>
</tbody>
</table>
<p>适用场景</p>
<p>Docker Compose适用场景</p>
<ul>
<li>本地开发环境：快速启动多个关联服务(如前端+后端+数据库)</li>
<li>单机测试：验证多容器应用的交互逻辑</li>
<li>简单项目部署：小型项目或原型验证</li>
</ul>
<p>Kubernetes适用场景</p>
<ul>
<li>生产环境部署：需要高可用性，自动恢复，滚动更新</li>
<li>大规模集群管理：跨多个节点动态调度容器</li>
<li>微服务架构：服务发现，流量管理，金丝雀发布</li>
<li>混合云/多云部署：统一管理跨云平台的容器</li>
</ul>
<p>配置文件示例：</p>
<p>Docker Compose（docker-compose.yml）</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">version</span>: <span style="color:#e6db74">&#34;3.8&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">service</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">web</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">nginx</span>:<span style="color:#a6e22e">latest</span>
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">ports</span>:
</span></span><span style="display:flex;"><span>	  <span style="color:#f92672">-</span> <span style="color:#e6db74">&#34;8080:80&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">db</span>:
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">postgres</span>: <span style="color:#ae81ff">13</span>
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">volumns</span>:
</span></span><span style="display:flex;"><span>	  <span style="color:#f92672">-</span> <span style="color:#a6e22e">db_data</span>: <span style="color:#f92672">/</span><span style="color:#66d9ef">var</span><span style="color:#f92672">/</span><span style="color:#a6e22e">lib</span><span style="color:#f92672">/</span><span style="color:#a6e22e">postgresql</span><span style="color:#f92672">/</span><span style="color:#a6e22e">data</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">volumns</span>:
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">db_data</span>:
</span></span></code></pre></div><p>Kubernetes（deployment.yaml + service.yaml）</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">deployment</span>.<span style="color:#a6e22e">yaml</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">apiVersion</span>: <span style="color:#a6e22e">apps</span><span style="color:#f92672">/</span><span style="color:#a6e22e">v1</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">kind</span>: <span style="color:#a6e22e">Deployment</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">metadata</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">nginx</span><span style="color:#f92672">-</span><span style="color:#a6e22e">deployment</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">spec</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">replicas</span>: <span style="color:#ae81ff">3</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">selector</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">matchLabels</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">app</span>: <span style="color:#a6e22e">nginx</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">template</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">metadata</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">labels</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">app</span>: <span style="color:#a6e22e">nginx</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">spec</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">containers</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">nginx</span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">nginx</span>:<span style="color:#a6e22e">latest</span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">ports</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">-</span> <span style="color:#a6e22e">containerPort</span>: <span style="color:#ae81ff">80</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">---</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">service</span>.<span style="color:#a6e22e">yaml</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">apiVersion</span>: <span style="color:#a6e22e">v1</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">kind</span>: <span style="color:#a6e22e">Service</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">metadata</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">nginx</span><span style="color:#f92672">-</span><span style="color:#a6e22e">service</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">spec</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">type</span>: <span style="color:#a6e22e">LoadBalancer</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">selector</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">app</span>: <span style="color:#a6e22e">nginx</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">ports</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">-</span> <span style="color:#a6e22e">port</span>: <span style="color:#ae81ff">80</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">targetPort</span>: <span style="color:#ae81ff">80</span>
</span></span></code></pre></div><p>关键差异总结</p>
<table>
<thead>
<tr>
<th>维度</th>
<th>Docker Compose</th>
<th>Kubernetes</th>
</tr>
</thead>
<tbody>
<tr>
<td>部署范围</td>
<td>单机</td>
<td>多接点集群</td>
</tr>
<tr>
<td>自动扩展</td>
<td>不支持</td>
<td>支持（HPA, Cluster Autoscaler）</td>
</tr>
<tr>
<td>服务发现</td>
<td>手动配置容器别名</td>
<td>通过Service和DNS自动发现</td>
</tr>
<tr>
<td>故障恢复</td>
<td>需手动重启容器</td>
<td>自动重启Pod, 节点故障转移</td>
</tr>
<tr>
<td>更新策略</td>
<td>需手动停止并重启容器</td>
<td>滚动更新，蓝绿部署，金丝雀发布</td>
</tr>
<tr>
<td>存储管理</td>
<td>本地卷或简单命名卷</td>
<td>动态卷供应，支持云存储</td>
</tr>
<tr>
<td>网络模型</td>
<td>简单容器间通信</td>
<td>多租户网络隔离，网络策略</td>
</tr>
</tbody>
</table>
<p>如何选择</p>
<ul>
<li>
<p>选择Docker Compose:</p>
<ul>
<li>本地开发，快速验证多容器交互</li>
<li>单机部署简单应用</li>
<li>无需复杂运维能力</li>
</ul>
</li>
<li>
<p>选择Kubernetes:</p>
<ul>
<li>生产环境需要高可用和弹性扩展</li>
<li>管理大规模微服务架构</li>
<li>需要自动化运维(自愈，滚动更新)</li>
</ul>
</li>
</ul>
<p>互补场景</p>
<ul>
<li>
<p>开发与生产分离：</p>
<p>在开发阶段使用Docker Compose快速搭建环境，生产环境使用Kubernetes部署</p>
</li>
<li>
<p>工具链整合：</p>
<p>使用Kompose工具将docker-compose.yml转换为Kubernetes资源配置(适合过度阶段)</p>
</li>
</ul>
<p>总结： 轻量化开发选Docker Compose, 生产级部署选Kubernetes</p>
<p>安装k8s:</p>
<p>所有节点通用配置：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">关闭</span> <span style="color:#a6e22e">Swap</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">swapoff</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">a</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">sed</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">i</span> <span style="color:#960050;background-color:#1e0010">&#39;</span><span style="color:#f92672">/</span> <span style="color:#a6e22e">swap</span> <span style="color:#f92672">/</span> <span style="color:#a6e22e">s</span><span style="color:#f92672">/</span>^<span style="color:#960050;background-color:#1e0010">\</span>(.<span style="color:#f92672">*</span><span style="color:#960050;background-color:#1e0010">\</span>)<span style="color:#960050;background-color:#1e0010">$</span><span style="color:#f92672">/</span><span style="color:#960050;background-color:#1e0010">#\</span><span style="color:#ae81ff">1</span><span style="color:#f92672">/</span><span style="color:#a6e22e">g</span><span style="color:#960050;background-color:#1e0010">&#39;</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">fstab</span>  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">永久禁用</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">设置主机名</span><span style="color:#960050;background-color:#1e0010">（</span><span style="color:#a6e22e">主节点</span><span style="color:#960050;background-color:#1e0010">）</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">hostnamectl</span> <span style="color:#a6e22e">set</span><span style="color:#f92672">-</span><span style="color:#a6e22e">hostname</span> <span style="color:#a6e22e">k8s</span><span style="color:#f92672">-</span><span style="color:#a6e22e">master</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">工作节点</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">hostnamectl</span> <span style="color:#a6e22e">set</span><span style="color:#f92672">-</span><span style="color:#a6e22e">hostname</span> <span style="color:#a6e22e">k8s</span><span style="color:#f92672">-</span><span style="color:#a6e22e">node1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">将主机名写入</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">hosts</span><span style="color:#960050;background-color:#1e0010">（</span><span style="color:#a6e22e">所有节点</span><span style="color:#960050;background-color:#1e0010">）</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">vi</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">hosts</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">添加以下内容</span><span style="color:#960050;background-color:#1e0010">（</span><span style="color:#a6e22e">替换为实际</span> <span style="color:#a6e22e">IP</span><span style="color:#960050;background-color:#1e0010">）</span>
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">192.168.1.100</span> <span style="color:#a6e22e">k8s</span><span style="color:#f92672">-</span><span style="color:#a6e22e">master</span>
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">192.168.1.101</span> <span style="color:#a6e22e">k8s</span><span style="color:#f92672">-</span><span style="color:#a6e22e">node1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">加载内核模块</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">cat</span> <span style="color:#f92672">&lt;&lt;</span><span style="color:#a6e22e">EOF</span> | <span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">tee</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">modules</span><span style="color:#f92672">-</span><span style="color:#a6e22e">load</span>.<span style="color:#a6e22e">d</span><span style="color:#f92672">/</span><span style="color:#a6e22e">k8s</span>.<span style="color:#a6e22e">conf</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">overlay</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">br_netfilter</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">EOF</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">modprobe</span> <span style="color:#a6e22e">overlay</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">modprobe</span> <span style="color:#a6e22e">br_netfilter</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">配置网络参数</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">cat</span> <span style="color:#f92672">&lt;&lt;</span><span style="color:#a6e22e">EOF</span> | <span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">tee</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">sysctl</span>.<span style="color:#a6e22e">d</span><span style="color:#f92672">/</span><span style="color:#a6e22e">k8s</span>.<span style="color:#a6e22e">conf</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">net</span>.<span style="color:#a6e22e">bridge</span>.<span style="color:#a6e22e">bridge</span><span style="color:#f92672">-</span><span style="color:#a6e22e">nf</span><span style="color:#f92672">-</span><span style="color:#a6e22e">call</span><span style="color:#f92672">-</span><span style="color:#a6e22e">iptables</span>  = <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">net</span>.<span style="color:#a6e22e">bridge</span>.<span style="color:#a6e22e">bridge</span><span style="color:#f92672">-</span><span style="color:#a6e22e">nf</span><span style="color:#f92672">-</span><span style="color:#a6e22e">call</span><span style="color:#f92672">-</span><span style="color:#a6e22e">ip6tables</span> = <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">net</span>.<span style="color:#a6e22e">ipv4</span>.<span style="color:#a6e22e">ip_forward</span>                 = <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">EOF</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">sysctl</span> <span style="color:#f92672">--</span><span style="color:#a6e22e">system</span>
</span></span></code></pre></div><p>2.安装容器运行时(以containerd为例)</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">yum</span> <span style="color:#a6e22e">install</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">y</span> <span style="color:#a6e22e">containerd</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">配置</span> <span style="color:#a6e22e">containerd</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">mkdir</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">p</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">containerd</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">containerd</span> <span style="color:#a6e22e">config</span> <span style="color:#66d9ef">default</span> | <span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">tee</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">containerd</span><span style="color:#f92672">/</span><span style="color:#a6e22e">config</span>.<span style="color:#a6e22e">toml</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">sed</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">i</span> <span style="color:#960050;background-color:#1e0010">&#39;</span><span style="color:#a6e22e">s</span><span style="color:#f92672">/</span><span style="color:#a6e22e">SystemdCgroup</span> = <span style="color:#66d9ef">false</span><span style="color:#f92672">/</span><span style="color:#a6e22e">SystemdCgroup</span> = <span style="color:#66d9ef">true</span><span style="color:#f92672">/</span><span style="color:#a6e22e">g</span><span style="color:#960050;background-color:#1e0010">&#39;</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">containerd</span><span style="color:#f92672">/</span><span style="color:#a6e22e">config</span>.<span style="color:#a6e22e">toml</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">systemctl</span> <span style="color:#a6e22e">restart</span> <span style="color:#a6e22e">containerd</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">systemctl</span> <span style="color:#a6e22e">enable</span> <span style="color:#a6e22e">containerd</span>
</span></span></code></pre></div><p>3.安装Kubernetes组件</p>
<ul>
<li>
<p>添加Kubernetes源</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">CentOS</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">cat</span> <span style="color:#f92672">&lt;&lt;</span><span style="color:#a6e22e">EOF</span> | <span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">tee</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">yum</span>.<span style="color:#a6e22e">repos</span>.<span style="color:#a6e22e">d</span><span style="color:#f92672">/</span><span style="color:#a6e22e">kubernetes</span>.<span style="color:#a6e22e">repo</span>
</span></span><span style="display:flex;"><span>[<span style="color:#a6e22e">kubernetes</span>]
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">name</span>=<span style="color:#a6e22e">Kubernetes</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">baseurl</span>=<span style="color:#a6e22e">https</span>:<span style="color:#75715e">//pkgs.k8s.io/core:/stable:/v1.28/rpm/
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#a6e22e">enabled</span>=<span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">gpgcheck</span>=<span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">gpgkey</span>=<span style="color:#a6e22e">https</span>:<span style="color:#75715e">//pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#a6e22e">EOF</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">yum</span> <span style="color:#a6e22e">clean</span> <span style="color:#a6e22e">all</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">yum</span> <span style="color:#a6e22e">makecache</span>
</span></span></code></pre></div></li>
<li>
<p>安装kubeadm, kubelet, kubectl</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">CentOS</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">yum</span> <span style="color:#a6e22e">install</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">y</span> <span style="color:#a6e22e">kubelet</span> <span style="color:#a6e22e">kubeadm</span> <span style="color:#a6e22e">kubectl</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">systemctl</span> <span style="color:#a6e22e">enable</span> <span style="color:#f92672">--</span><span style="color:#a6e22e">now</span> <span style="color:#a6e22e">kubelet</span>
</span></span></code></pre></div></li>
</ul>
<p>3.初始化控制平面(Master节点)</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">初始化集群</span><span style="color:#960050;background-color:#1e0010">（</span><span style="color:#a6e22e">替换</span> &lt;<span style="color:#a6e22e">master</span><span style="color:#f92672">-</span><span style="color:#a6e22e">ip</span>&gt; <span style="color:#a6e22e">为实际</span> <span style="color:#a6e22e">IP</span><span style="color:#960050;background-color:#1e0010">）</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">kubeadm</span> <span style="color:#a6e22e">init</span> \
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">--</span><span style="color:#a6e22e">apiserver</span><span style="color:#f92672">-</span><span style="color:#a6e22e">advertise</span><span style="color:#f92672">-</span><span style="color:#a6e22e">address</span>=&lt;<span style="color:#a6e22e">master</span><span style="color:#f92672">-</span><span style="color:#a6e22e">ip</span>&gt; \
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">--</span><span style="color:#a6e22e">control</span><span style="color:#f92672">-</span><span style="color:#a6e22e">plane</span><span style="color:#f92672">-</span><span style="color:#a6e22e">endpoint</span>=<span style="color:#a6e22e">k8s</span><span style="color:#f92672">-</span><span style="color:#a6e22e">master</span> \
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">--</span><span style="color:#a6e22e">pod</span><span style="color:#f92672">-</span><span style="color:#a6e22e">network</span><span style="color:#f92672">-</span><span style="color:#a6e22e">cidr</span>=<span style="color:#ae81ff">10.244.0.0</span><span style="color:#f92672">/</span><span style="color:#ae81ff">16</span> \
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">--</span><span style="color:#a6e22e">image</span><span style="color:#f92672">-</span><span style="color:#a6e22e">repository</span>=<span style="color:#a6e22e">registry</span>.<span style="color:#a6e22e">aliyuncs</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">google_containers</span>  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">国内镜像源</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">配置</span> <span style="color:#a6e22e">kubectl</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">mkdir</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">p</span> <span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">HOME</span><span style="color:#f92672">/</span>.<span style="color:#a6e22e">kube</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">cp</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">i</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">kubernetes</span><span style="color:#f92672">/</span><span style="color:#a6e22e">admin</span>.<span style="color:#a6e22e">conf</span> <span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">HOME</span><span style="color:#f92672">/</span>.<span style="color:#a6e22e">kube</span><span style="color:#f92672">/</span><span style="color:#a6e22e">config</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">chown</span> <span style="color:#960050;background-color:#1e0010">$</span>(<span style="color:#a6e22e">id</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">u</span>):<span style="color:#960050;background-color:#1e0010">$</span>(<span style="color:#a6e22e">id</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">g</span>) <span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">HOME</span><span style="color:#f92672">/</span>.<span style="color:#a6e22e">kube</span><span style="color:#f92672">/</span><span style="color:#a6e22e">config</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">查看节点状态</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">get</span> <span style="color:#a6e22e">nodes</span>  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">应显示</span> <span style="color:#a6e22e">NotReady</span><span style="color:#960050;background-color:#1e0010">（</span><span style="color:#a6e22e">等待网络插件安装</span><span style="color:#960050;background-color:#1e0010">）</span>
</span></span></code></pre></div><p>4.安装网络插件(Calico)</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">apply</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">f</span> <span style="color:#a6e22e">https</span>:<span style="color:#75715e">//raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/calico.yaml
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">等待</span> <span style="color:#a6e22e">Pod</span> <span style="color:#a6e22e">就绪</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">get</span> <span style="color:#a6e22e">pods</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">n</span> <span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">system</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">w</span>
</span></span></code></pre></div><p>5.加入工作节点</p>
<p>在工作节点执行以下命令（命令来自Master初始化时的输出）</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">kubeadm</span> <span style="color:#a6e22e">join</span> &lt;<span style="color:#a6e22e">master</span><span style="color:#f92672">-</span><span style="color:#a6e22e">ip</span>&gt;:<span style="color:#ae81ff">6443</span> <span style="color:#f92672">--</span><span style="color:#a6e22e">token</span> &lt;<span style="color:#a6e22e">token</span>&gt; <span style="color:#f92672">--</span><span style="color:#a6e22e">discovery</span><span style="color:#f92672">-</span><span style="color:#a6e22e">token</span><span style="color:#f92672">-</span><span style="color:#a6e22e">ca</span><span style="color:#f92672">-</span><span style="color:#a6e22e">cert</span><span style="color:#f92672">-</span><span style="color:#a6e22e">hash</span> &lt;<span style="color:#a6e22e">hash</span>&gt;
</span></span></code></pre></div><p>6.验证集群状态</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">get</span> <span style="color:#a6e22e">nodes</span>  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">所有节点应显示</span> <span style="color:#a6e22e">Ready</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">get</span> <span style="color:#a6e22e">pods</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">A</span>  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">检查系统</span> <span style="color:#a6e22e">Pod</span> <span style="color:#a6e22e">是否全部</span> <span style="color:#a6e22e">Running</span>
</span></span></code></pre></div><p>7.快速测试集群</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">部署测试应用</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">create</span> <span style="color:#a6e22e">deployment</span> <span style="color:#a6e22e">nginx</span> <span style="color:#f92672">--</span><span style="color:#a6e22e">image</span>=<span style="color:#a6e22e">nginx</span>:<span style="color:#a6e22e">latest</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">expose</span> <span style="color:#a6e22e">deployment</span> <span style="color:#a6e22e">nginx</span> <span style="color:#f92672">--</span><span style="color:#a6e22e">port</span>=<span style="color:#ae81ff">80</span> <span style="color:#f92672">--</span><span style="color:#66d9ef">type</span>=<span style="color:#a6e22e">NodePort</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">获取访问端口</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">get</span> <span style="color:#a6e22e">svc</span> <span style="color:#a6e22e">nginx</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">浏览器访问</span> <span style="color:#a6e22e">http</span>:<span style="color:#75715e">//&lt;节点IP&gt;:&lt;NodePort&gt;
</span></span></span></code></pre></div><p><img src="https://www.lican.asia/images/k8s/1742798613230.png" alt="1742798613230"></p>
<p>常见问题解决</p>
<p>1.镜像拉取失败</p>
<ul>
<li>
<p>使用国内镜像源：</p>
<p>在 <code>kubeadm init</code> 时指定 <code>--image-repository=registry.aliyuncs.com/google_containers</code></p>
</li>
<li>
<p>手动拉取镜像：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">kubeadm</span> <span style="color:#a6e22e">config</span> <span style="color:#a6e22e">images</span> <span style="color:#a6e22e">pull</span> <span style="color:#f92672">--</span><span style="color:#a6e22e">image</span><span style="color:#f92672">-</span><span style="color:#a6e22e">repository</span>=<span style="color:#a6e22e">registry</span>.<span style="color:#a6e22e">aliyuncs</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">google_containers</span>
</span></span></code></pre></div></li>
</ul>
<p>2.节点NotReady</p>
<ul>
<li>
<p>检查网络插件：</p>
<p>确保Calico/Flannel Pod正常运行：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">kubectl</span> <span style="color:#a6e22e">get</span> <span style="color:#a6e22e">pods</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">n</span> <span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">system</span> | <span style="color:#a6e22e">grep</span> <span style="color:#a6e22e">calico</span>
</span></span></code></pre></div></li>
</ul>
<p>3.重置集群</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">kubeadm</span> <span style="color:#a6e22e">reset</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sudo</span> <span style="color:#a6e22e">rm</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">rf</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">cni</span><span style="color:#f92672">/</span><span style="color:#a6e22e">net</span>.<span style="color:#a6e22e">d</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">kubernetes</span><span style="color:#f92672">/</span> <span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">HOME</span><span style="color:#f92672">/</span>.<span style="color:#a6e22e">kube</span>
</span></span></code></pre></div><p>4.查看k8s系统镜像</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">ctr</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">n</span> <span style="color:#a6e22e">k8s</span>.<span style="color:#a6e22e">io</span> <span style="color:#a6e22e">images</span> <span style="color:#a6e22e">ls</span> | <span style="color:#a6e22e">grep</span> <span style="color:#a6e22e">calico</span><span style="color:#f92672">/</span><span style="color:#a6e22e">cni</span>
</span></span></code></pre></div><p>5.手动下载并导入镜像</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">从</span> <span style="color:#a6e22e">Docker</span> <span style="color:#a6e22e">Hub</span> <span style="color:#a6e22e">拉取镜像</span><span style="color:#960050;background-color:#1e0010">（</span><span style="color:#a6e22e">默认源</span><span style="color:#960050;background-color:#1e0010">）</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">docker</span> <span style="color:#a6e22e">pull</span> <span style="color:#a6e22e">calico</span><span style="color:#f92672">/</span><span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">controllers</span>:<span style="color:#a6e22e">v3</span><span style="color:#ae81ff">.26.1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">或使用阿里云镜像加速</span><span style="color:#960050;background-color:#1e0010">（</span><span style="color:#a6e22e">推荐中国大陆用户</span><span style="color:#960050;background-color:#1e0010">）</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">docker</span> <span style="color:#a6e22e">pull</span> <span style="color:#a6e22e">registry</span>.<span style="color:#a6e22e">aliyuncs</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">calico</span><span style="color:#f92672">/</span><span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">controllers</span>:<span style="color:#a6e22e">v3</span><span style="color:#ae81ff">.26.1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">查看已拉取的镜像</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">docker</span> <span style="color:#a6e22e">images</span> | <span style="color:#a6e22e">grep</span> <span style="color:#a6e22e">calico</span><span style="color:#f92672">/</span><span style="color:#a6e22e">kube</span><span style="color:#f92672">-</span><span style="color:#a6e22e">controllers</span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">导出</span> <span style="color:#a6e22e">Docker</span> <span style="color:#a6e22e">镜像为</span> <span style="color:#a6e22e">tar</span> <span style="color:#a6e22e">文件</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">docker</span> <span style="color:#a6e22e">save</span> <span style="color:#a6e22e">calico</span><span style="color:#f92672">/</span><span style="color:#a6e22e">cni</span>:<span style="color:#a6e22e">v3</span><span style="color:#ae81ff">.26.1</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">o</span> <span style="color:#a6e22e">calico</span><span style="color:#f92672">-</span><span style="color:#a6e22e">cni</span>.<span style="color:#a6e22e">tar</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">导入到</span> <span style="color:#a6e22e">containerd</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">ctr</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">n</span> <span style="color:#a6e22e">k8s</span>.<span style="color:#a6e22e">io</span> <span style="color:#a6e22e">images</span> <span style="color:#f92672">import</span> <span style="color:#a6e22e">calico</span><span style="color:#f92672">-</span><span style="color:#a6e22e">cni</span>.<span style="color:#a6e22e">tar</span>
</span></span></code></pre></div>

                                        
                                    </div>

                                    

                                    

                                    
                                    
                                    

                                </div>
                            </article>
                        </div>
                    </div>
                </section>
                <aside class="sidebar sidebar-primary" id="sidebar-primary" role="complementary">
    <h1 class="screen-reader-text">Sidebar</h1>
    

    
    
    <section id="text-2" class="widget widget_text">
        <div class="textwidget">
            
            <div id="profile">
                <div id="profile_picture"><img src="https://www.lican.asia/logo/logo.png"></div>
                <div id="profile_intro">
                    <p><span class="name">Lican</span></p>
                    <p class="intro">全栈开发者，爱好造轮子。</p>
                </div>
            </div>
            
            <p>
                <script type="text/javascript">
                    (function ($) {
                        $(document).ready(function () {
                            var menuPrimaryContainer = $('#menu-primary-container');
                            var profile = $('#text-2');
                            $('#toggle-navigation').click(function () {
                                if (menuPrimaryContainer.hasClass('open')) {
                                    profile.removeClass('open');
                                } else {
                                    profile.addClass('open');
                                }
                            });
                        });
                    })(jQuery);
                </script>
            </p>
        </div>
    </section>
    
    
    
    
    
    <section id="text-5" class="widget widget_text">
        <h2 class="widget-title">开源项目</h2>
        <div class="textwidget">
            <div id="projects" style="line-height: 22px;">
                
                <a href="https://github.com/idoubi/gonews"
                    target="_blank">gonews</a>: &nbsp;Daily news for golang<br>
                
                <a href="https://github.com/idoubi/sql2struct"
                    target="_blank">sql2struct</a>: &nbsp;Generate go struct according to SQL<br>
                
                <a href="https://github.com/idoubi/goz"
                    target="_blank">goz</a>: &nbsp;Request library used in golang<br>
                
        </div>
    </section>
    
    

    
    
    
    
    <section id="qrcode" class="widget widget_media_image">
        <h2 class="widget-title">微信公众号</h2>
        <img width="258" height="258"
            src="https://www.lican.asia/wechat/lican.png"
            class="image wp-image-5514  attachment-full size-full" alt=""
            style="max-width: 100%; height: auto;"
            sizes="(max-width: 258px) 100vw, 258px">
    </section>
    
    

    
    
    

    
    
    

    
    
    
    
</aside>
            </div>
        </div>

        <footer id="site-footer" class="site-footer" role="contentinfo">
    <div class="max-width">
    </div>
    <div class="footer">
        <div id="footercontent">
            © lican.asia All rights reserved<br/>
            Built with Hugo Theme <a href="https://github.com/idoubi/hugo-theme-period" target="_blank">Period</a>
        </div>
    </div>
</footer>

<script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?e8351b6d4626d5881d439ea1f6184baa";
      var s = document.getElementsByTagName("script")[0]; 
      s.parentNode.insertBefore(hm, s);
    })();
</script>
    
    
    </div>
    
</body>

</html>